﻿Imports extranet.BE
Imports extranet.DA

Public Class BCNoticia

  Public Shared Function Listar() As List(Of Noticia)
    Dim noticias As List(Of Noticia)
    Dim noticiaDao As New DA.NoticiaDAO()
    noticias = noticiaDao.listar()
    Return noticias
  End Function

  Public Shared Function Selecionar(ByVal id As Integer) As Noticia
    Dim noticiaDao As New DA.NoticiaDAO()
    Return noticiaDao.selecionar(New Noticia(id))
  End Function

  Public Shared Function SelecionarImagem(ByVal id As Integer) As Byte()
    Dim noticiaDao As New DA.NoticiaDAO()
    Return noticiaDao.selecionarImagem(New Noticia(id))
  End Function

  Public Shared Sub Salvar(ByVal noticia As Noticia)
    Dim noticiaDao As New DA.NoticiaDAO()
    If noticia.Id = -1 Then
      noticiaDao.inserir(noticia)
    Else
      noticiaDao.atualizar(noticia)
    End If
  End Sub

  Public Shared Sub Deletar(ByVal noticia As Noticia)
    Dim noticiaDao As New DA.NoticiaDAO()
    If noticia.Id > 0 Then noticiaDao.deletar(noticia)
  End Sub

  Public Shared Sub Desativar(ByVal noticia As Noticia)
    Dim noticiaDao As New DA.NoticiaDAO()
    If Not noticia.Id = -1 Then
      noticiaDao.desativar(noticia)
    End If
  End Sub

  Public Shared Function PesquisarSimples(ByVal strFiltro As String)
    Dim noticiaDao As New DA.NoticiaDAO()
    Return noticiaDao.PesquisarSimples(strFiltro)
  End Function

  Public Shared Function PesquisarAvancada(ByVal txtBuscaExpressao As String, ByVal txtBuscaQualquer As String, ByVal txtBuscaSem As String, ByVal txtBuscaTodas As String)
    Dim noticiaDao As New DA.NoticiaDAO()
    Return noticiaDao.PesquisarAvancada(txtBuscaExpressao, txtBuscaQualquer, txtBuscaSem, txtBuscaTodas)
  End Function

End Class

